module.exports = function(path){
  return new Promise((resolve,reject)=>{
    wx.request({
      url: 'http://127.0.0.1:8081/api/' + path,
      method: 'GET',
      success:resolve,
      fail:reject
    })
  })
}
function get_from(path, param){
  return new Promise((resolve,reject)=>{
    wx.request({
      url: 'http://127.0.0.1:8081/api/' + path,
      method: 'GET',
      data: param,
      success:resolve,
      fail:reject
    });
  })
}

function post_to(path, data){
  return new Promise((resolve,reject)=>{
    wx.request({
      url: 'http://127.0.0.1:8081/api/' + path,
      method: 'POST',
      data: data,
      header: {
        'Content-Type': 'application/json'
      },
      success:resolve,
      fail:reject
    });
  })
}

module.exports.get_from = get_from
module.exports.post_to = post_to